import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
import config from "@/config";
import Layout from "@/page/index";

const title = config.title;

import Login from "@/view/Login";
import Register from "@/view/Register";


const routes = [
  {
    path: "/login",
    name: "登录",
    component: Login
  },
  {
    path: "/register",
    name: "注册",
    component: Register
  },
  {
    path: "/",
    name: "PageView",
    component: Layout,
    children: [
      {
        path: "/",
        redirect: "/home"
      },
      {
        path: "/home",
        name: "home",
        component: resolve => require(["@/view/HomePage"], resolve),
        meta: {
          title: title + "-首页"
        }
      },
      {
        path: "/course",
        name: "courseList",
        component: resolve => require(["@/view/course/list"], resolve),
        meta: {
          title: title + "-课程"
        }
      },
      {
        path: "/course/detail",
        name: "courseDetail",
        component: resolve =>
          require(["@/view/course/detail"], resolve),
        meta: {
          title: "课程详情"
        }
      },
      {
        path: "/course",
        name: "Course",
        redirect: "/course/list",
        children: [
          {
            path: "/course/list",
            name: "courseList",
            component: resolve =>
              require(["@/view/course/list"], resolve),
            meta: {
              title: title + "-课程"
            }
          },
          {
            path: "/course/detail",
            name: "courseDetail",
            component: resolve =>
              require(["@/view/course/detail"], resolve),
            meta: {
              title: "课程详情"
            }
          },
        ]
      },
      {
        path: "/recommend",
        name: "Recommend",
        component: resolve => require(["@/view/course/recommend"], resolve),
        meta: {
          title: title + "-推荐"
        }
      },
      {
        path: "/service",
        name: "service",
        component: resolve => require(["@/view/Service"], resolve),
        meta: {
          title: title + "-相关服务"
        }
      },
      {
        path: "/newsinformation",
        name: "newsinformation",
        component: resolve => require(["@/view/NewsInformation"], resolve),
        meta: {
          title: title + "-新闻动态"
        }
      },
      {
        path: "/newsinformationdetail",
        name: "newsinformationdetail",
        component: resolve =>
          require(["@/view/NewsInformationDetail"], resolve),
        meta: {
          title: title + "-新闻详情"
        }
      },
      {
        path: "/companyintroduction",
        name: "companyintroduction",
        component: resolve => require(["@/view/CompanyIntroduction"], resolve),
        meta: {
          title: title + "-公司介绍"
        }
      },
      {
        path: "/contactus",
        name: "contactus",
        component: resolve => require(["@/view/ContactUs"], resolve),
        meta: {
          title: title + "-联系我们"
        }
      },
      {
        path: "/servicedetail",
        name: "servicedetail",
        component: resolve => require(["@/view/ServiceDetail"], resolve),
        meta: {
          title: title + "-相关服务"
        }
      }
    ]
  }
];

const router = new VueRouter({
  mode: "hash",
  /*hash模式改为history*/
  routes
  // （缩写）相当于 routes: routes
});

export default router;
